<template>
  <div>
    <el-form label-width="120px">
      <el-form-item label="克隆:">
        初始的：toRawAr:<br />
        ===>>{{ toRawAr }}<br />
        toRawAr.clone() :<br />
        ===>>{{ toRawAr.clone() }}
      </el-form-item>
      <el-form-item label="清空:">
        toRawAr.clear() :<br />
        ===>>{{ toRawAr.clear() }}
      </el-form-item>
      <el-form-item label="添加数组:">
        改变的是原数组，不会重新创建新数组 :<br />
        toRawAr.merge([3,5,6,6,7]) :<br />
        ===>>{{ toRawAr.merge([3,5,6,6,7]) }}<br />
        toRawAr :<br />
        ===>>{{ toRawAr }}
      </el-form-item>
      <el-form-item label="是否包含元素:">
        toRawAr.contains(5) :<br />
        ===>>{{ toRawAr.contains(5) }}
      </el-form-item>

      <el-form-item label="查找下标:">
        toRawAr.indexOf("Taobao") :<br />
        ===>>{{ toRawAr.indexOf(6) }}
      </el-form-item>
      <el-form-item label="查找最后下标 :">
        toRawAr.lastIndexOf("Taobao") :<br />
        ===>>{{ toRawAr.lastIndexOf(6) }}
      </el-form-item>
      <el-form-item label="简单去重 :">
        toRawAr.unique() :<br />
        ===>>{{ toRawAr.unique() }}
      </el-form-item>

      <el-form-item label="查找数组中最大 :">
        toRawAr.max() :<br />
        ===>>{{ toRawAr.max() }}
      </el-form-item>
      <el-form-item label="查找数组中最小 :">
        toRawAr.min() :<br />
        ===>>{{ toRawAr.min() }}
      </el-form-item>
      
      <!-- <el-form-item>
        <el-input v-model.number="myval.arr[0]" placeholder="请输入内容">
          <template #prepend>arr[0]:</template>
        </el-input>
        <el-input v-model.number="myval.arr[1]" placeholder="请输入内容">
          <template #prepend>arr[1]:</template>
        </el-input>
        <el-input v-model.number="myval.arr[2]" placeholder="请输入内容">
          <template #prepend>arr[2]:</template>
        </el-input>
        <el-input v-model.number="myval.arr[3]" placeholder="请输入内容">
          <template #prepend>arr[3]:</template>
        </el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="reset">重置</el-button>
      </el-form-item> -->
    </el-form>
  </div>
</template>

<script lang="ts">
import {toRaw,reactive,computed} from 'vue'
export default {
    data() {
       // eslint-disable-next-line @typescript-eslint/no-unused-vars
       let myar: number[];
        // eslint-disable-next-line prefer-const
        myar = [1,2,3,3];
        const clonearr = myar.clone();
        clonearr.push("百度")
        console.log( "拷贝后的对象，c.clone();c.push('百度')===》",clonearr)
        console.log( "被拷贝的对象没变===》",myar)
        const myval = reactive({
          arr:[...myar]
        });
        const reset = ()=>{
            
            myval.arr = [...myar];
            
        }
        const toRawAr = computed(()=>{
          const re = toRaw(myval);
          //console.log(re.arr)
          return re.arr;
        })
        reset();
        return {
            myval,
            reset,
            toRawAr
        }
    }
}
</script>
